<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class CreateModerationRemarksTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('moderation_remarks', function (Blueprint $table) {
            $table->id()->from(config('migration.from'));

            $table->bigInteger('profile_id')->unsigned()->nullable();
            $table->foreign('profile_id')->references('id')->on('profiles')->onDelete('set null')->onUpdate('cascade');

            $table->bigInteger('moderation_id')->unsigned();
            $table->foreign('moderation_id')->references('id')->on('moderations')->onDelete('cascade')->onUpdate('cascade');

            $table->string('type_key')->unsigned()->nullable()->comment('Тип Заметки');
            $table->foreign('type_key')->references('key')->on('types')->onDelete('restrict')->onUpdate('restrict');

            $table->longText('message');

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('moderation_remarks');
    }
}
